//
//  ThreeTableViewCell.m
//  WangI
//
//  Created by 陈曦 on 15/11/23.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "ThreeTableViewCell.h"
#import "UIImageView+ShowImage.h"
@implementation ThreeTableViewCell
-(void)dealloc {
    [_view release];
    [_title release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.title];
        [_title release];
        [self addSubview:self.view];
        [_view release];
    }
    return self;
}
-(void)setModel:(ToutiaoModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    NSArray *array = [[NSArray alloc] initWithObjects:_model.imgsrc, _model.imagearray[0], _model.imagearray[1], nil];
    for (int i = 0; i < 3; i++) {
        UIImageView *image = (UIImageView *)[_view viewWithTag:100 + i];
        [image WXZM:array[i]];
    }
    _title.text = _model.title;
}
-(UILabel *)title {
    if (!_title) {
        self.title = [[UILabel alloc] initWithFrame:CGRectZero];
        _title.font = [UIFont systemFontOfSize:13];
        [_title release];
    }
    return _title;
}
-(UIView *)view {
    if (!_view) {
        self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 90)];
        for (int i = 0; i < 3; i++) {
            UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(15 + (self.bounds.size.width / 3 + 15) * i, 0, (self.bounds.size.width - 40) / 3, 90)];
            image.tag = 100 + i;
            [_view addSubview:image];
            image.backgroundColor = [UIColor redColor];
            [image release];
        }
        return _view;
    }
    return _view;
}
-(void)layoutSubviews {
    [super layoutSubviews];
    _title.frame = CGRectMake(5, 3, self.bounds.size.width - 100, 13);
    _view.frame = CGRectMake(0, 20, self.bounds.size.width, 90);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
